import cv2
import numpy

imread = cv2.imread(r'/Users/likai/Downloads/美女图片.jpg')
# cv2.imshow(" image",imread)

####第一题
'高斯过滤器'
gaussian_blur = cv2.GaussianBlur(imread, (19,19), 0)
cv2.imshow(" imreadGauss image",gaussian_blur)

'改变大小'
resize = cv2.resize(gaussian_blur, ((int)(imread.shape[1]/2),(int)(imread.shape[0]/2)), interpolation=cv2.INTER_CUBIC)
cv2.imshow(" resize image",resize)

'缩小一半'
down = cv2.pyrDown(imread)
cv2.imshow(" down image",down)

'扩大一倍'
up = cv2.pyrUp(imread)
cv2.imshow(" up image",up)

color = cv2.cvtColor(imread, cv2.COLOR_BGR2GRAY)
cv2.imshow(" color image", color)


ret, threshold =cv2.threshold(color, 120, 255, cv2.THRESH_BINARY)
print(type(threshold))
cv2.imshow(" threshold image", threshold)



####第二题

cvt_color = cv2.cvtColor(imread, cv2.COLOR_BGR2HSV)
imshow = cv2.imshow(" cvt_color image", cvt_color)

cvt_color_split = cv2.split(cvt_color)

imshow = cv2.imshow(" cvt_color_split_1 image", cvt_color_split[0])
imshow = cv2.imshow(" cvt_color_split_2 image", cvt_color_split[1])
imshow = cv2.imshow(" cvt_color_split_3 image", cvt_color_split[2])

imread_split = cv2.split(imread)

imshow = cv2.imshow(" imread_split_1 image", imread_split[0])
imshow = cv2.imshow(" imread_split_2 image", imread_split[1])
imshow = cv2.imshow(" imread_split_3 image", imread_split[2])


cv2.waitKey()
cv2.destroyAllWindows()